// Copyright 2007 Google Inc.
// All Rights Reserved.

package com.google.jessewilson.codesearch.gtagssearch;

import com.google.jessewilson.codesearch.api.SearchProvider;
import com.google.jessewilson.codesearch.api.spi.SearchProviderParameters;
import com.google.jessewilson.codesearch.io.jdom.EasyElement;
import com.google.jessewilson.codesearch.io.jdom.Externalizer;

import org.jdom.Element;

/**
 * Currently empty.  At some point, this class should be modified such that
 * it holds options like "whole words only" and "language type".
 *
 * @see GtagsSearchProviderParametersEditor
 * @author Ted Mao (tmao@google.com)
 */
class GtagsSearchProviderParameters implements SearchProviderParameters {

  private final boolean findInvocations;

  public GtagsSearchProviderParameters(boolean findInvocations) {
    this.findInvocations = findInvocations;
  }

  public boolean findInvocations() {
    return findInvocations;
  }

  public SearchProvider getSearchProvider() {
    return new GtagsSearchProvider();
  }

  public static class MyExternalizer
      implements Externalizer<GtagsSearchProviderParameters> {

    private static final String FIND_INVOCATIONS = "findInvocations";

    public void writeExternal(Element target, GtagsSearchProviderParameters data) {
      EasyElement queryExtraElement = new EasyElement(target);
      queryExtraElement.putBoolean(FIND_INVOCATIONS, data.findInvocations);
    }

    public GtagsSearchProviderParameters readExternal(Element source) {
      EasyElement queryExtraElement = new EasyElement(source);
      boolean findInvocations = queryExtraElement.getBoolean(FIND_INVOCATIONS, false);
      return new GtagsSearchProviderParameters(findInvocations);
    }

  }
}